function resolveAfter1Seconds() { //将异步过程包装为Promise
    return new Promise(resolve => {
        setTimeout(() => {
            resolve('已成功');
        }, 1000);
    });
}
async function asyncFunc() { //定义async函数
    console.log('正在执行async函数');
    var result = await resolveAfter1Seconds(); // await表达式
    console.log(result); // 输出'已成功' 
}
asyncFunc(); //调用async函数
console.log('async函数代码开始执行');